package cn.ad.server.domain.ad;

import java.io.Serializable;
import java.util.Date;

public class PlatformAdspaceMap implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7496719030863728693L;
	static final String VERSION = "0";
	static final String CACHE_NAME = "platformadspacemap";
	
	private long id;
	private int channelId;
//	private Channel channel;
	private String platformTagId;
	private int platformId;
	private long adSpaceId;
	private int status;
	private Date createTime;
	private Date updateTime;

	public static String cacheKey(long id) {
		return new StringBuilder(CACHE_NAME).append(":").append(VERSION).append(":").append(id).toString();
	}

	public String toCacheKey() {
		return new StringBuilder(CACHE_NAME).append(":").append(VERSION).append(":").append(this.getId()).toString();
	}

	public static String cacheTagIdKey(String tagId, int channel) {
		return new StringBuilder(CACHE_NAME).append(":").append(VERSION).append(":").append(getChannelTagId(tagId,channel)).toString();
	}

	public String toCacheTagIdKey() {
		return new StringBuilder(CACHE_NAME).append(":").append(VERSION).append(":").append(this.getChannelTagId()).toString();
	}

	public static String getChannelTagId(String tagId, int channel) {
		return channel+","+tagId;
	}
	
	private String getChannelTagId() {
		return getChannelTagId(platformTagId, channelId);
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public int getChannelId() {
		return channelId;
	}

	public void setChannelId(int channelId) {
		this.channelId = channelId;
	}

	public String getPlatformTagId() {
		return platformTagId;
	}

	public void setPlatformTagId(String platformTagId) {
		this.platformTagId = platformTagId;
	}

	public long getAdSpaceId() {
		return adSpaceId;
	}

	public void setAdSpaceId(long adSpaceId) {
		this.adSpaceId = adSpaceId;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public boolean equals(Object arg0) {
		if (arg0 == null)
			return false;
		if (arg0 instanceof PlatformAdspaceMap) {
			return this.id == ((PlatformAdspaceMap) arg0).id;
		} else {
			return super.equals(arg0);
		}
	}

	public int hashCode() {
		return Long.valueOf(id).hashCode();
	}

	public int getPlatformId() {
		return platformId;
	}

	public void setPlatformId(int platformId) {
		this.platformId = platformId;
	}

}
